//
//  WhileIfTest.cpp
//  MNNTests
//
//  Created by MNN on 2020/02/13.
//  Copyright © 2018, Alibaba Group Holding Limited
//


#include <MNN/expr/Expr.hpp>
#include <MNN/expr/ExprCreator.hpp>
#include <MNN/expr/Executor.hpp>
#include <string>
#include <map>
#define MNN_OPEN_TIME_TRACE
#include <MNN/AutoTime.hpp>
#include "MNNTestSuite.h"

using namespace MNN;
using namespace MNN::Express;

// Tf model:
/*
with tf.variable_scope('conv'):
    a = tf.constant(1)
    b = tf.constant(2)
    c = tf.placeholder(tf.int32, name='count', shape = [])
    d = tf.constant(9)
    def cond(a, b, c, d):
        return a<c

    def body(a, b, c, d):
        a += 1
        b += 3
        d = tf.cond(b < 15, lambda: tf.add(d, 4), lambda: tf.add(d, 8))
        return a, b, c, d # same with [a, b, c]
    a ,b, c, d = tf.while_loop(cond, body, [a,b,c,d], parallel_iterations = 1)
    e = tf.add(d, tf.add(a, tf.add(b, c)))
*/

// The model will be seperate to two part:
// First as mnn model to record all executable ops
// Second as cpp code to resolve control-flow
static unsigned char while_if_mnn[] = {
  0x1c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x18, 0x00, 0x08, 0x00, 0x0c, 0x00,
  0x00, 0x00, 0x05, 0x00, 0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
  0x06, 0x00, 0x07, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
  0x64, 0x03, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x41, 0x6c, 0x69, 0x4e,
  0x4e, 0x54, 0x65, 0x73, 0x74, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00,
  0x1c, 0x03, 0x00, 0x00, 0xfc, 0x02, 0x00, 0x00, 0xe0, 0x02, 0x00, 0x00,
  0xc0, 0x02, 0x00, 0x00, 0x98, 0x02, 0x00, 0x00, 0x78, 0x02, 0x00, 0x00,
  0x58, 0x02, 0x00, 0x00, 0x3c, 0x02, 0x00, 0x00, 0x24, 0x02, 0x00, 0x00,
  0x08, 0x02, 0x00, 0x00, 0xec, 0x01, 0x00, 0x00, 0xd8, 0x01, 0x00, 0x00,
  0xc4, 0x01, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00, 0x94, 0x01, 0x00, 0x00,
  0x78, 0x01, 0x00, 0x00, 0x60, 0x01, 0x00, 0x00, 0x48, 0x01, 0x00, 0x00,
  0x28, 0x01, 0x00, 0x00, 0x0c, 0x01, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00,
  0xd4, 0x00, 0x00, 0x00, 0xb8, 0x00, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00,
  0x80, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00,
  0x3c, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
  0x18, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x77, 0x68, 0x69,
  0x6c, 0x65, 0x2f, 0x63, 0x6f, 0x6e, 0x64, 0x2f, 0x53, 0x77, 0x69, 0x74,
  0x63, 0x68, 0x3a, 0x31, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00,
  0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x00, 0x00,
  0x0c, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x43, 0x6f, 0x6e,
  0x73, 0x74, 0x5f, 0x31, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00,
  0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x00, 0x00,
  0x0e, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x77, 0x68, 0x69,
  0x6c, 0x65, 0x2f, 0x61, 0x64, 0x64, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
  0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x61,
  0x64, 0x64, 0x2f, 0x79, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
  0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x53,
  0x77, 0x69, 0x74, 0x63, 0x68, 0x3a, 0x31, 0x00, 0x11, 0x00, 0x00, 0x00,
  0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x4c,
  0x65, 0x73, 0x73, 0x5f, 0x31, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
  0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x4c,
  0x65, 0x73, 0x73, 0x5f, 0x31, 0x2f, 0x79, 0x00, 0x10, 0x00, 0x00, 0x00,
  0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x61,
  0x64, 0x64, 0x5f, 0x31, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00,
  0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x61,
  0x64, 0x64, 0x5f, 0x31, 0x2f, 0x79, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00,
  0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x53,
  0x77, 0x69, 0x74, 0x63, 0x68, 0x5f, 0x31, 0x3a, 0x31, 0x00, 0x00, 0x00,
  0x0c, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x43, 0x6f, 0x6e,
  0x73, 0x74, 0x5f, 0x32, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
  0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x4c,
  0x65, 0x73, 0x73, 0x00, 0x12, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76,
  0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x4d, 0x65, 0x72, 0x67, 0x65,
  0x5f, 0x32, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76,
  0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x4d, 0x65, 0x72, 0x67, 0x65,
  0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76,
  0x2f, 0x41, 0x64, 0x64, 0x5f, 0x32, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00,
  0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x41, 0x64, 0x64, 0x5f, 0x31, 0x00, 0x00,
  0x08, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x41, 0x64, 0x64,
  0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76,
  0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x45, 0x78, 0x69, 0x74, 0x5f,
  0x32, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76,
  0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x45, 0x78, 0x69, 0x74, 0x5f,
  0x31, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76,
  0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x45, 0x78, 0x69, 0x74, 0x00,
  0x11, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x77, 0x68, 0x69,
  0x6c, 0x65, 0x2f, 0x45, 0x78, 0x69, 0x74, 0x5f, 0x33, 0x00, 0x00, 0x00,
  0x15, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x77, 0x68, 0x69,
  0x6c, 0x65, 0x2f, 0x63, 0x6f, 0x6e, 0x64, 0x2f, 0x41, 0x64, 0x64, 0x5f,
  0x31, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76,
  0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x63, 0x6f, 0x6e, 0x64, 0x2f,
  0x41, 0x64, 0x64, 0x5f, 0x31, 0x2f, 0x79, 0x00, 0x1c, 0x00, 0x00, 0x00,
  0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x63,
  0x6f, 0x6e, 0x64, 0x2f, 0x41, 0x64, 0x64, 0x5f, 0x31, 0x2f, 0x53, 0x77,
  0x69, 0x74, 0x63, 0x68, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00,
  0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x63,
  0x6f, 0x6e, 0x64, 0x2f, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68, 0x00, 0x00,
  0x13, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x77, 0x68, 0x69,
  0x6c, 0x65, 0x2f, 0x63, 0x6f, 0x6e, 0x64, 0x2f, 0x41, 0x64, 0x64, 0x00,
  0x15, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x77, 0x68, 0x69,
  0x6c, 0x65, 0x2f, 0x63, 0x6f, 0x6e, 0x64, 0x2f, 0x41, 0x64, 0x64, 0x2f,
  0x79, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76,
  0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x63, 0x6f, 0x6e, 0x64, 0x2f,
  0x41, 0x64, 0x64, 0x2f, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68, 0x3a, 0x31,
  0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0xe4, 0x09, 0x00, 0x00,
  0x70, 0x09, 0x00, 0x00, 0xfc, 0x08, 0x00, 0x00, 0x90, 0x08, 0x00, 0x00,
  0x30, 0x08, 0x00, 0x00, 0xd8, 0x07, 0x00, 0x00, 0x7c, 0x07, 0x00, 0x00,
  0x28, 0x07, 0x00, 0x00, 0xd8, 0x06, 0x00, 0x00, 0x84, 0x06, 0x00, 0x00,
  0x30, 0x06, 0x00, 0x00, 0xe0, 0x05, 0x00, 0x00, 0x90, 0x05, 0x00, 0x00,
  0x40, 0x05, 0x00, 0x00, 0xec, 0x04, 0x00, 0x00, 0x98, 0x04, 0x00, 0x00,
  0x44, 0x04, 0x00, 0x00, 0xf4, 0x03, 0x00, 0x00, 0x9c, 0x03, 0x00, 0x00,
  0x48, 0x03, 0x00, 0x00, 0xf0, 0x02, 0x00, 0x00, 0x9c, 0x02, 0x00, 0x00,
  0x44, 0x02, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0x9c, 0x01, 0x00, 0x00,
  0x48, 0x01, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00,
  0x60, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x16, 0xf7, 0xff, 0xff,
  0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00,
  0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x92, 0xf6, 0xff, 0xff,
  0x00, 0x00, 0x00, 0x02, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
  0x1d, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76,
  0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x63, 0x6f, 0x6e, 0x64, 0x2f,
  0x53, 0x77, 0x69, 0x74, 0x63, 0x68, 0x3a, 0x31, 0x00, 0x00, 0x00, 0x00,
  0x6e, 0xf7, 0xff, 0xff, 0x00, 0x00, 0x20, 0x01, 0x12, 0x00, 0x00, 0x00,
  0x2c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
  0x5c, 0xf7, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00,
  0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00,
  0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x00, 0x00,
  0xb6, 0xf7, 0xff, 0xff, 0x00, 0x00, 0x20, 0x01, 0x12, 0x00, 0x00, 0x00,
  0x2c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
  0xa4, 0xf7, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00,
  0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
  0x01, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
  0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x5f, 0x31,
  0x00, 0x00, 0x00, 0x00, 0x92, 0xf7, 0xff, 0xff, 0x00, 0x00, 0x06, 0x01,
  0x03, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
  0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x0c, 0x00, 0x00, 0x00,
  0x08, 0x00, 0x07, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
  0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00,
  0x0a, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x63, 0x6f, 0x75,
  0x6e, 0x74, 0x00, 0x00, 0xba, 0xf8, 0xff, 0xff, 0x00, 0x00, 0x1a, 0x01,
  0x13, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
  0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa8, 0xf8, 0xff, 0xff,
  0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x19, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
  0x18, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76,
  0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x61, 0x64, 0x64, 0x00, 0x00,
  0x9a, 0xf8, 0xff, 0xff, 0x00, 0x00, 0x20, 0x01, 0x12, 0x00, 0x00, 0x00,
  0x2c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
  0x88, 0xf8, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00,
  0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
  0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x61,
  0x64, 0x64, 0x2f, 0x79, 0x00, 0x00, 0x00, 0x00, 0xea, 0xf8, 0xff, 0xff,
  0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00,
  0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x66, 0xf8, 0xff, 0xff,
  0x00, 0x00, 0x00, 0x02, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
  0x17, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76,
  0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x53, 0x77, 0x69, 0x74, 0x63,
  0x68, 0x3a, 0x31, 0x00, 0xaa, 0xf9, 0xff, 0xff, 0x00, 0x00, 0x1a, 0x01,
  0x13, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
  0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x98, 0xf9, 0xff, 0xff,
  0x0c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x16, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
  0x15, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76,
  0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x4c, 0x65, 0x73, 0x73, 0x5f,
  0x31, 0x00, 0x00, 0x00, 0x8e, 0xf9, 0xff, 0xff, 0x00, 0x00, 0x20, 0x01,
  0x12, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
  0x04, 0x00, 0x00, 0x00, 0x7c, 0xf9, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01,
  0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x0f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00,
  0x13, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x77, 0x68, 0x69,
  0x6c, 0x65, 0x2f, 0x4c, 0x65, 0x73, 0x73, 0x5f, 0x31, 0x2f, 0x79, 0x00,
  0x4e, 0xfa, 0xff, 0xff, 0x00, 0x00, 0x1a, 0x01, 0x13, 0x00, 0x00, 0x00,
  0x30, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
  0x04, 0x00, 0x00, 0x00, 0x3c, 0xfa, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
  0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
  0x02, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
  0x10, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x77, 0x68, 0x69,
  0x6c, 0x65, 0x2f, 0x61, 0x64, 0x64, 0x5f, 0x31, 0x00, 0x00, 0x00, 0x00,
  0x32, 0xfa, 0xff, 0xff, 0x00, 0x00, 0x20, 0x01, 0x12, 0x00, 0x00, 0x00,
  0x2c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
  0x20, 0xfa, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00,
  0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
  0x01, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00,
  0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x61,
  0x64, 0x64, 0x5f, 0x31, 0x2f, 0x79, 0x00, 0x00, 0x82, 0xfa, 0xff, 0xff,
  0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00,
  0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xfe, 0xf9, 0xff, 0xff,
  0x00, 0x00, 0x00, 0x02, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
  0x12, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76,
  0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x53, 0x77, 0x69, 0x74, 0x63,
  0x68, 0x5f, 0x31, 0x3a, 0x31, 0x00, 0x00, 0x00, 0xd6, 0xfa, 0xff, 0xff,
  0x00, 0x00, 0x20, 0x01, 0x12, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00,
  0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xc4, 0xfa, 0xff, 0xff,
  0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
  0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x11, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76,
  0x2f, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x5f, 0x32, 0x00, 0x00, 0x00, 0x00,
  0x92, 0xfb, 0xff, 0xff, 0x00, 0x00, 0x1a, 0x01, 0x13, 0x00, 0x00, 0x00,
  0x30, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
  0x04, 0x00, 0x00, 0x00, 0x80, 0xfb, 0xff, 0xff, 0x0c, 0x00, 0x00, 0x00,
  0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
  0x02, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
  0x0f, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x77, 0x68, 0x69,
  0x6c, 0x65, 0x2f, 0x4c, 0x65, 0x73, 0x73, 0x00, 0x72, 0xfb, 0xff, 0xff,
  0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00,
  0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xee, 0xfa, 0xff, 0xff,
  0x00, 0x00, 0x00, 0x02, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
  0x0f, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76,
  0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x4d, 0x65, 0x72, 0x67, 0x65,
  0x5f, 0x32, 0x00, 0x00, 0xc2, 0xfb, 0xff, 0xff, 0x00, 0x00, 0x06, 0x01,
  0x03, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
  0x04, 0x00, 0x00, 0x00, 0x3e, 0xfb, 0xff, 0xff, 0x00, 0x00, 0x00, 0x02,
  0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
  0x10, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x77, 0x68, 0x69,
  0x6c, 0x65, 0x2f, 0x4d, 0x65, 0x72, 0x67, 0x65, 0x00, 0x00, 0x00, 0x00,
  0x82, 0xfc, 0xff, 0xff, 0x00, 0x00, 0x1a, 0x01, 0x13, 0x00, 0x00, 0x00,
  0x30, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
  0x04, 0x00, 0x00, 0x00, 0x70, 0xfc, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
  0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00,
  0x02, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
  0x0a, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x41, 0x64, 0x64,
  0x5f, 0x32, 0x00, 0x00, 0xce, 0xfc, 0xff, 0xff, 0x00, 0x00, 0x1a, 0x01,
  0x13, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
  0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xbc, 0xfc, 0xff, 0xff,
  0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
  0x0b, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76,
  0x2f, 0x41, 0x64, 0x64, 0x5f, 0x31, 0x00, 0x00, 0x1a, 0xfd, 0xff, 0xff,
  0x00, 0x00, 0x1a, 0x01, 0x13, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
  0x20, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
  0x08, 0xfd, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
  0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
  0x09, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
  0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x41, 0x64, 0x64, 0x00, 0x00, 0x00, 0x00,
  0xf6, 0xfc, 0xff, 0xff, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00,
  0x2c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
  0x72, 0xfc, 0xff, 0xff, 0x00, 0x00, 0x00, 0x02, 0x08, 0x00, 0x00, 0x00,
  0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
  0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00,
  0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x45,
  0x78, 0x69, 0x74, 0x5f, 0x32, 0x00, 0x00, 0x00, 0x46, 0xfd, 0xff, 0xff,
  0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00,
  0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xc2, 0xfc, 0xff, 0xff,
  0x00, 0x00, 0x00, 0x02, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
  0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76,
  0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x45, 0x78, 0x69, 0x74, 0x5f,
  0x31, 0x00, 0x00, 0x00, 0x96, 0xfd, 0xff, 0xff, 0x00, 0x00, 0x06, 0x01,
  0x03, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
  0x04, 0x00, 0x00, 0x00, 0x12, 0xfd, 0xff, 0xff, 0x00, 0x00, 0x00, 0x02,
  0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
  0x0f, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x77, 0x68, 0x69,
  0x6c, 0x65, 0x2f, 0x45, 0x78, 0x69, 0x74, 0x00, 0xe2, 0xfd, 0xff, 0xff,
  0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00,
  0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x5e, 0xfd, 0xff, 0xff,
  0x00, 0x00, 0x00, 0x02, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
  0x07, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76,
  0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x45, 0x78, 0x69, 0x74, 0x5f,
  0x33, 0x00, 0x00, 0x00, 0xa2, 0xfe, 0xff, 0xff, 0x00, 0x00, 0x1a, 0x01,
  0x13, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
  0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x90, 0xfe, 0xff, 0xff,
  0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
  0x05, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76,
  0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x63, 0x6f, 0x6e, 0x64, 0x2f,
  0x41, 0x64, 0x64, 0x5f, 0x31, 0x00, 0x00, 0x00, 0x8a, 0xfe, 0xff, 0xff,
  0x00, 0x00, 0x20, 0x01, 0x12, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00,
  0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x78, 0xfe, 0xff, 0xff,
  0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
  0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x05, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76,
  0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x63, 0x6f, 0x6e, 0x64, 0x2f,
  0x41, 0x64, 0x64, 0x5f, 0x31, 0x2f, 0x79, 0x00, 0xde, 0xfe, 0xff, 0xff,
  0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00,
  0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x5a, 0xfe, 0xff, 0xff,
  0x00, 0x00, 0x00, 0x02, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
  0x04, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76,
  0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x63, 0x6f, 0x6e, 0x64, 0x2f,
  0x41, 0x64, 0x64, 0x5f, 0x31, 0x2f, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68,
  0x00, 0x00, 0x00, 0x00, 0x3a, 0xff, 0xff, 0xff, 0x00, 0x00, 0x06, 0x01,
  0x03, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
  0x04, 0x00, 0x00, 0x00, 0xb6, 0xfe, 0xff, 0xff, 0x00, 0x00, 0x00, 0x02,
  0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
  0x16, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x77, 0x68, 0x69,
  0x6c, 0x65, 0x2f, 0x63, 0x6f, 0x6e, 0x64, 0x2f, 0x53, 0x77, 0x69, 0x74,
  0x63, 0x68, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x1c, 0x00, 0x08, 0x00,
  0x0c, 0x00, 0x10, 0x00, 0x14, 0x00, 0x06, 0x00, 0x18, 0x00, 0x07, 0x00,
  0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x01, 0x13, 0x00, 0x00, 0x00,
  0x38, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00,
  0x0c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x04, 0x00, 0x08, 0x00,
  0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
  0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
  0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x63,
  0x6f, 0x6e, 0x64, 0x2f, 0x41, 0x64, 0x64, 0x00, 0x00, 0x00, 0x12, 0x00,
  0x18, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x06, 0x00,
  0x14, 0x00, 0x07, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x01,
  0x12, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00,
  0x10, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x00, 0x00, 0x08, 0x00,
  0x07, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
  0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x15, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x77, 0x68, 0x69,
  0x6c, 0x65, 0x2f, 0x63, 0x6f, 0x6e, 0x64, 0x2f, 0x41, 0x64, 0x64, 0x2f,
  0x79, 0x00, 0x12, 0x00, 0x1a, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x00, 0x00,
  0x10, 0x00, 0x06, 0x00, 0x14, 0x00, 0x07, 0x00, 0x12, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00,
  0x2c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00,
  0x10, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x07, 0x00, 0x0a, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x02, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x76,
  0x2f, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2f, 0x63, 0x6f, 0x6e, 0x64, 0x2f,
  0x41, 0x64, 0x64, 0x2f, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68, 0x3a, 0x31,
  0x00, 0x00, 0x00, 0x00
};
unsigned int while_if_mnn_len = 3544;


#define UP_DIV(x) (((x)+3)/4)
static void extraCall(std::map<std::string, VARP>& varMap) {
auto v4 = varMap["conv/Const"];
auto v6 = varMap["conv/Const_1"];
auto v8 = varMap["conv/count"];
auto v10 = varMap["conv/Const_2"];
auto v12 = v4;
varMap["conv/while/Merge"]->input(v12);
auto v16 = v6;
auto v13 = v8;
varMap["conv/while/Merge_2"]->input(v13);
auto v17 = v10;
auto v15 = varMap["conv/while/Less"];
while(v15->readMap<int>()[0] > 0) {
auto v18 = varMap["conv/while/Merge"];
varMap["conv/while/Switch:1"]->input(v18);
auto v19 = v16;
varMap["conv/while/Switch_1:1"]->input(v19);
auto v20 = varMap["conv/while/Merge_2"];
auto v21 = v17;
VARP v30;
VARP v29;
if (varMap["conv/while/Less_1"]->readMap<int>()[0] <= 0){
v30 = varMap["conv/while/Less_1"];
}
else {
v29 = varMap["conv/while/Less_1"];
}
varMap["conv/while/cond/Switch"]->input(v30);
varMap["conv/while/cond/Switch:1"]->input(v29);
VARP v54;
VARP v32;

if (varMap["conv/while/Less_1"]->readMap<int>()[0] <= 0){
v54 = v21;
}
else {
v32 = v21;
}
varMap["conv/while/cond/Add/Switch:1"]->input(v32);
VARP v37;
if (varMap["conv/while/Less_1"]->readMap<int>()[0] <= 0){
v37 = v21;
}
varMap["conv/while/cond/Add_1/Switch"]->input(v37);
VARP v43;
 do
 {
if (varMap["conv/while/cond/Add_1"]->getInfo() != nullptr) {
v43 = varMap["conv/while/cond/Add_1"];
break;
}
if (varMap["conv/while/cond/Add"]->getInfo() != nullptr) {
v43 = varMap["conv/while/cond/Add"];
break;
}
} while (false);

v12 = _Clone(varMap["conv/while/add"], true);
varMap["conv/while/Merge"]->input(v12);
v16 = _Clone(varMap["conv/while/add_1"], true);
v13 = _Clone(v20, true);
varMap["conv/while/Merge_2"]->input(v13);
v17 = _Clone(v43, true);
}
auto v50 = v12;
varMap["conv/while/Exit"]->input(v50);
auto v48 = v16;
varMap["conv/while/Exit_1"]->input(v48);
auto v49 = v13;
varMap["conv/while/Exit_2"]->input(v49);
auto v52 = v17;
varMap["conv/while/Exit_3"]->input(v52);
}

class WhileIfTest : public MNNTestCase {
public:
    virtual ~WhileIfTest() = default;
    virtual bool run() {
        auto varMap = Variable::loadMap(while_if_mnn, sizeof(while_if_mnn));
        varMap["conv/count"]->writeMap<int32_t>()[0] = 10;
        extraCall(varMap);
        int result = varMap["conv/Add_2"]->readMap<int32_t>()[0];
        return result == 114;
    }
};

MNNTestSuiteRegister(WhileIfTest, "expr/while_if");
